def read4(buf4):
    return 1


class Solution(object):
    def __init__(self):
        self.count = 0
        self.k = 0
        self.temp = [" "] * 4

    def read(self, buf, n):
        """
        :type buf: List[str]
        :type n: int
        :rtype: int
        """
        now_count = 0
        while self.count - self.k < n:
            for k in range(self.k, self.count):
                buf[now_count] = self.temp[k]
                now_count += 1
                n -= 1
            self.temp = [" "] * 4
            self.count = read4(self.temp)
            self.k = 0
            if self.count < 4:
                break
        k = 0
        while k < min(self.count - self.k, n):
            buf[now_count] = self.temp[self.k + k]
            k += 1
            now_count += 1
        self.k += k
        return now_count

